package com.example.food_contract_system.controller;

import com.example.food_contract_system.service.AppealService;
import com.example.food_contract_system.util.R;
import com.example.food_contract_system.vo.InsertAppealVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiHaoyang
 * @date 2023/7/14  9:01
 **/
@RestController
@RequestMapping("/appeal")
public class AppealController {

    @Autowired
    private AppealService appealService;

    @PostMapping("/insertAppeal")
    public R insertAppeal(@RequestBody InsertAppealVo insertAppealVo){
        R result = appealService.insertAppeal(insertAppealVo);
        return result;
    }

    @GetMapping("/getAppeal/{aId}")
    public R getAppeal(@PathVariable("aId")String aId){
        R result = appealService.getAppeal(aId);
        return result;
    }

    @PostMapping("/sendAnswer/{aId}/{appId}")
    public R sendAnswer(@PathVariable("aId") String aId,
                        @PathVariable("appId") String appId,
                        @RequestBody String msg){
        R result = appealService.sendAnswer(aId,msg,appId);
        return result;
    }

    @GetMapping("/deleteAppeal/{appId}")
    public R deleteAppeal(@PathVariable("appId") String appId){
        R result = appealService.deleteAppeal(appId);
        return result;
    }
}
